home *** CD-ROM | disk | FTP | other *** search
- PrnUtil
- -------
-
- PrnUtil contains routines to handle printer output while checking
- for printer errors as well as user input. PrnUtil keeps track of
- line and page numbers making report pagination as easy as
- possible. It includes routines for redirecting output to disk
- files as well as redirecting to a network printer (Novell,
- requires Turbo Power's B-Tree Filer - NetWare unit). It also
- includes routines for printing formatted heading and footing
- lines. This unit requires Turbo Professional 5.0 for compilation
- as well as the Messages and IOError units which I have written.
- If Network printing is desired, requires B-Tree Filer's NetWare
- unit and DataEntry, a small field entry unit which was written
- for small field entry tasks before TPEntry was released and
- modified to work with version 5.0 of the Turbo Power routines.
-
-
-
-
- Constants
-
- MaxLineLength = 132
-
- This is the maximum length for strings passed to PrnUtil's print
- routines.
-
- PrnDatePic : DateString = 'mm/dd/yy'
- PrnTimePic : DateString = 'hh:mm te'
-
- These set the way the time and date will appear in printed
- strings formatted using the PercentExpand function.
-
- Types
-
- PageLine = String[MaxLineLength]
-
- This defines the base string type passed to all print routines.
-
- JustType = (Left, Right, middle);
-
- Describes how strings can be justified by the PrintJust
- procedure.
-
- Variables
-
- PrnPort : byte
-
- This is the printer port that PrnUtil will use when sending
- output to the printer, 0 for LPT1, 1 for LPT2, etc. Defaults to
- 0.
-
- PrnCanceled : boolean
-
- This will be true if a print job has been cancelled by a user by
- pressing ESC at a printer error message or by pausing the
- printing and pressing ESC. While PrnCanceled is true, all print
- commands are ignored.
-
- PrnStatus : byte
-
- PrnStatus will always contain the status of the printer after the
- last print operation. PrnStatus is a bit mapped byte with the
- following information:
-
- 7 6 5 4 3 2 1 0
- │ │ │ │ │ │
- │ │ │ │ │ └── Printer time out
- │ │ │ │ └────────────── Printer I/O error
- │ │ │ └────────────────── Printer online
- │ │ └────────────────────── Printer out of paper
- │ └────────────────────────── Printer Acknowledge
- └────────────────────────────── Printer not busy
-
-
-
- PrintToFile : boolean
-
- If set to True, all printer output will be routed to the file
- PrnFile which must be opened by the calling program using
- OpenPrnFile which sets this to true if successful.
-
- PrnIOResult : word
-
- The saved value of IOResult if a file I/O error occurs when
- printing to a disk file.
-
- PrnFile : Text
-
- File to print to if PrnToFile is true. This file must be opened
- by the calling program using OpenPrnFile.
-
- CurrLine : byte
- CurrPage : word
-
- The current line and page numbers being printed. These should
- not be altered by the calling program in most circumstances, they
- are exported mostly for inspection by the calling program for
- pagination.
-
- PageLength,
- PageWidth : byte
-
- The current number of lines per page and number of columns per
- page. Defaults to 66 lines, 80 columns.
-
- FootingLine : byte
-
- This is the line number where the footing will be placed by the
- NewPage procedure.
-
- PrnInFileName : String[64]
-
- This is the string that will print for the %F in strings passed
- to the PercentExpand function.
-
- PrnErrorAttr : byte
-
- This is the attribute of the pop up windows describing printer
- errors or print job status.
-
- NetOK : boolean
-
- If network printing is enabled (compiled with the NetPrint
- directive defined). This will be true if the network drivers are
- installed and the user is logged in.
-
- Capturing : boolean
-
- If network printing is enabled, this will be true if output is
- being captured to a network printer.
-
- Procedures and Functions
-
- procedure Print(St : PageLine)
-
- Prints St to the current printer or file, does not advance to the
- next line. Checks printer status before printing and displays
- error message in pop up window promptine user to correct problem
- or press ESC. If a key has been pressed, will prompt user to
- press another key to continue or press ESC to cancel printing.
-
- procedure PrintLn(St : PageLine)
-
- Prints St to the current printer of file, advancing to the next
- line when done. See Print procedure for more.
-
- function PercentExpand( S: String ): String
-
- Formats a string containing embedded commands. The commands
- should be preceeded by a percent (%) sign and will be interpreted
- and/or replaced as follows:
-
- %F - Replace with PrnInfileName which must be initialized by
- the calling program.
- %# - Replace with current page number.
- %T - Replace with system time (formatted by PrnTimePic).
- %D - Replace with system date (Formatted by PrnDatePic).
- %< - Left justify entire line.
- %> - Right justify entire line (dependent on PageWidth).
- %[ - Alternate Left justify Even/Odd pages
- %] - Alternate Right justify Even/Odd pages
-
- procedure PrintJust(Line : PageLine;Just:Justtype)
-
- Prints a line justified in the manner specified by the Just
- parameter. Uses PrintLn to do the printing.
-
- procedure PrnSkiplines(Num : Integer)
-
- Skips the specified number of lines.
-
- procedure NewPage(Footer : PageLine)
-
- Advances to the top of the next page. Prints PercentExpand(
- Footer ) on line specified by FootingLine if it advances past
- that line.
-
- procedure PrnReset
-
- Resets the line and page counting variables to 1.
-
- procedure InitPrinter
-
- Initializes the printer port specified by PrnPort.
-
- function OpenPrnFile(FName: String): boolean
-
- Assigns and opens PrnFile for output and sets the variable
- PrintToFile to true if file is opened successfully. Notifies
- user in pop up window of I/O errors. If OpenPrnFile fails, the
- variable PrnCanceled is set to True.
-
- function ClosePrnFile(Fname: String): boolean
-
- Closes the PrnFile if it has been opened previously. Notifies
- users of any errors closing the file and prompts for retry or
- ESC to cancel. If ClosePrnFile fails (user pressed ESC to
- cancel), PrnCancelled is set to True. This routine will reset
- the variable PrnToFile to false in all cases. FName is used in
- reporting the error to the user.
-
-
-
- The following routines are exported only if the program is
- compiled with the NetPrint directive defined.
-
- function SetCapture( On : boolean ): boolean
-
- Starts or stops network print capturing. Returns true if
- successful.
-
- procedure SetPringOptions
-
- Allows user to select whether to print to network and to select a
- network printer number. If network printing is selected, it
- calls SetCapture. If user presses ESC while answering questions,
- PrnCanceled will be set to True on exit.
-
-